*----------------------------------------------------------------------------------------------------------	* 
* RESEARCHERS:		EARN												   									*
* PROGRAMMED BY:	Linea Hasager																			*
* DESCRIPTION:		Histogram of admissions per month											 	 		*
* CREATED:			Mar. 14, 2018																		   	*
* LAST MODIFIED:	May 26, 2022													       					*
*---------------------------------------------------------------------------------------------------------	*

clear 
set more off

// Directories
global in "L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Input"
global output "L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Output"
global temp "L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Temp"


*--------------------------------------------------------------------------------------------------------	

/* LOAD DATA*/
use "${in}\Population_jan_feb2001", replace




*DROP IF OLDER THAN 49
keep if age< 50

gen somalia=0
replace somalia=1 if opr_land==5289
label var somalia "Somalia"

*DROP IF FROM SOMALIA
keep if somalia==0



*MONTH NUMBER
gen month_nr=mofd(tilladelsesdato)
format %tmMon_CCYY month_nr
label variable month_nr "Month"


*MONTH NUMBER NORMLAIZED TO JANAURY 1999
gen m_nr=mofd(tilladelsesdato)-468
label variable m_nr "Months Since January 1st 1999"


*COUNT OBSERVATIONS IN EACH  MONTH BIN
bysort month_nr: egen antal=count(pnr)
label variable antal "Admissions per Month"



*HISTOGRAM: ADMISSIONS PER MONTH
histogram m_nr if month_nr <495 & (antal > 4 | antal==0), width(1)  legend(off) discrete addplot(pci 0 -0.5 0.05 -0.5, lcolor(black) lpattern(dash)) graphregion(color(white)) bcolor(gs12) lcolor(white) xtitle("Month of Admission") gap(10) tlabel(-24 -12 0 12 24, format(%10.0fc)) ylab(,format(%10.2fc))
graph export "${output}\oa_figure1a.png", as(png) replace width(5000)

